The main contents of this chapter:With previous learning, we learned and quickly completed the first spring boot application. Spring Boot Enterprise Framework, then how does spring boot read static resources? such as JS folder, CS
, neo4j, Redi, SOLR, etc.If we want to, do not need spring boot automatic configuration, want to turn off the automatic configuration of an item, how to set it?Welcome to the next article. We will answer in the next article.Other articles in this series:Spring Boot Framework Learn the important annotations of preschool mastery (1)-
1. External configurationSpring boot supports external configurations so that the same application code can be used in different environments. You can use properties files, YAML files, environment variables, or command line parameters for external configuration. You can use @value annotations to inject property values directly into a defined bean, access the property through spring's environment abstraction, or bind to a structured object by @configur
1. Configure the spring environment variablesIn the environment variable path add: D:\Program files\spring-boot-cli-1.5.8.release-bin\spring-1.5.8.release\binCmd:spring--versionJava--version2. Create a project using the SPRING-BOOT_CLI commandSpring init--build=maven--java-v
Pensionnumber;private status status;private String ip1;private String ip2;private String Ebutlerphonewsurl;... Public static Class status{private String success;private String Nouser;private String nobalance;private String unknown;。。。。。。}}Ip-phone:URL:ID:Key:Pensionnumber:ip1:IP2:Ebutlerphonewsurl:Status:success:0Nouser:4nobalance:16unknown:9995. Interceptors Handlerinterceptor blocked static resources by default in version 2.0.0 ResourceHandlermethod, skip the static resources.Handlermethod ob
"); @RequestMapping ("map") public map
Re-run Project: Access: Http://localhost:8080/admin/index
Visit: Http://localhost:8080/admin/map
Adding debugging
It's annoying to restart the project every time you modify the code.Project--Right key--spring tools--add Boot Devtools, then every time you modify the class file will be automatically compiled.
You can also modify Pom.xml to add Devtools dependencies
Spring INITIALIZR is a very effective spring boot when building projects, although Maven and the starter provided by spring boot are very simple to use, but because of the large number of components and associated parts, It is still nice to have such a visual configuration-b
Spring INITIALIZR is very effective when building projects, although the starter that MAVEN and spring boot provide are very simple to use, but because of the many components and associations, It's still nice to have such a visual configuration build management tool. In this article we will use spring INITIALIZR in Int
Spring Boot + spring Cloud microservice implementation tutorial 2, springcloud
The previous article has explained the simple steps for creating a maven project in spring boot. I believe that many people familiar with Maven + Eclip
Tagged: Ros images micro-service NIS res modular Fast comSpring Cloud-based microservices build learning-2 spring boot Why use spring boot instead of springSpring boot, with its automated configuration, rapid development, and ease
We complete our example by creating a fully self-contained executable jar file that can be run in production env. An executable jar (sometimes called a "fat jars") is an archive file that contains the classes you compile and all the jar dependencies your code needs to run.This example continues on the basis of Spring Boot (1): Guide.(1) Add the following dependencies in Maven:1 can be punched into a run
)
Execution java -jar xxx.jar --spring.profiles.active=prod , you can observe that the service port is set to 3333 , that is, the configuration of the production environment (PROD)
According to the above experiment, we can summarize the multi-environment configuration ideas as follows:
application.propertiesThe common content is configured in and set to the spring.profiles.active=dev development environment as the default configuration
application-{profile}.properti
engine (no separate Web server required), the service should start on its own at the command line, and be accessed immediately through the exposed HTTP port.Concurrency: To initiate more micro-service instances to scale horizontally when demand increases.Can be arbitrarily disposed of: you can start and stop as needed.The development environment is equivalent to the production environment: minimizing the gap between all the environments in which the service runs.LOG: Use the tool to log and vie
Spring Boot because of its1, easy to develop and maintain. 2, a single micro-service start fast. 3, local modification deployment is easy. 4, the technology stack is not subject to language restrictions and other advantages by more and more companies pay attention to. Spring-boot
[emailprotected]The above program will parse the value of the name and email parameters into the records in the user table in the database and save the browser interface such as:
Enter the URL Localhost:8080/demo/all in the browser and just look at the records we inserted into MySQL (in JSON format):
Finally we went to MySQL to see if the data was inserted successfully, as shown in the following:
Conclusion?? This article describes how
the default template path and so on. # Enable template caching. Spring.thymeleaf.cache=true # Check The templates location exists. Spring.thymeleaf.check-template-location=true # Content-type value. spring.thymeleaf.content-type=text/html # Enable MVC thymeleaf View resolution. Spring.thymeleaf.enabled=true # Template encoding. Spring.thymeleaf.encoding=utf-8 # comma-separated List of view names that should is excluded from resolution. spring.thymeleaf.excluded-view-names= # Template mode
It 's written in front .
This demo demonstrates how to troubleshoot a common spring expected single matching bean but found 2 exception.
Https://github.com/hengyunabc/spring-boot-inside/tree/master/demo-expected-single Debugging Troubleshooting expected single Matching Bean but found
"Spring Boot 2.x start the whole process of source analysis (a) Import class analysis" We analyzed the Spring boot entry class Springapplication source code, and know its construction principle, this we continue to analyze its core run method.[TOC]Springapplication instance
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.